package com.bw.controller;

import com.bw.doman.sugar;
import com.bw.doman.sugarTwo;
import com.bw.service.sugarService;
import com.sugar.SugarUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@RestController
public class sugarConntroller {
    @Autowired
    sugarService sugarService;

    @RequestMapping("list")
    public Map list(){
        List<sugar> list =sugarService.getList();
        return SugarUtil.getMapData(list);
    }

    @RequestMapping("list2")
    public Map list2(){
        List<sugar> list =sugarService.getList2();
        return SugarUtil.getBarData(list);
    }

    @RequestMapping("list3")
    public Map list3(){
        List<sugar> list =sugarService.getList3();
        return SugarUtil.getPieData(list);
    }

    @RequestMapping("list4")
    public String list4(){
        List<sugarTwo> list =sugarService.getList4();
        List list1 = new ArrayList<>();
        list1.add("新用户");
        list1.add("老用户");
        return SugarUtil.getTablePlayData(list1,list);
    }
}
